package fr.tocchisu.grepolis.services;

import java.io.BufferedReader;
import java.io.Console;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;

import fr.tocchisu.grepolis.model.Town;

public abstract class AbstractService {

	protected static final Town CAMPI = new Town("Campi", 37378, 8265, 8266, 8267, 8268, 8269, 8270, 8271, 8272);
	protected static final Town MATRA = new Town("Matra", 40410, 9529, 9530, 9532, 9534, 9535, 9536);
	protected static final Town MOITA = new Town("Moita", 40543, 7329, 7330, 7331, 7333, 7334, 7335, 7336);
	protected static final Town TALLONE = new Town("Tallone", 40612, 10465, 10466, 10467, 10468, 10469, 10470, 10472);
	protected static final Town NIHIL = new Town("Nihil", 34278, 13089, 13092, 13093, 13094, 13095, 13096);
	protected static final Town TOX = new Town("Tox", 41321, 14721, 14722, 14725, 14726, 14727, 14728);
	protected static final Town LINGUIZETTA = new Town("Linguizzetta", 38799, 14297, 14298, 14299, 14300, 14302, 14304);
	protected static final Town BASTIA = new Town("bastia", 35043, 13265, 13267, 13268, 13269, 13270, 13271, 13272);
	protected static final Town DUCLAIR = new Town("duclair", 37403, 10961, 10963, 10964, 10966, 10968);
	protected static final Town QUIMPER = new Town("quimper", 37893, 14139,14141,14142);
	protected static final Town ETRETAT = new Town("etretat", 21828);
	protected static final Town DINARD = new Town("dinard", 21814);
// Etretat 21828
	protected static final List<Town> TOWNS = Arrays.asList(new Town[] { CAMPI, MATRA, MOITA, TALLONE, NIHIL, TOX, LINGUIZETTA, BASTIA,
			DUCLAIR, QUIMPER, ETRETAT, DINARD });

	protected static String readLine(String prompt) {
		String line = null;
		Console c = System.console();
		if (c != null) {
			line = c.readLine(prompt);
		} else {
			System.out.print(prompt);
			BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
			try {
				line = bufferedReader.readLine();
			} catch (IOException e) {
				// Ignore
			}
		}
		return line;
	}
}